-- world - "World"

function autoexec()
  if (get_progress(P_CAVEDOOR) == 1) then
    set_mtile("cave_door", 54)
    set_obs("cave_door",0)
  end

 if (get_progress(P_CARAVEL) == 2) then

  set_ent_active(2,0)
  wait_for_entity(HERO1, HERO1)
  clear_buffer()
  screen_dump()
  do_fadein(25)
  --set_desc(0)
  set_autoparty(1)
  --set_vfollow(1)
  set_ent_speed(HERO1, 4)
  set_ent_script(HERO1, "R5D1R3D5R3D4R6D2R18U15R10U7R4U1R1")
  wait_for_entity(HERO1, HERO1)
  set_autoparty(0)
  change_map("villagex","caravel_enter"); 
end

 if (get_progress(P_CARAVEL) == 4) then

   set_ent_active(2,0);	
   wait_for_entity(HERO1, HERO1);
   clear_buffer();
   screen_dump();
   do_fadein(25);
  --set_desc(0)
   set_autoparty(1);
  --set_vfollow(1)
  -- set_ent_speed(HERO1, 4);
   set_ent_script(HERO1, "L1D1L4L40D10L4D1L1"); 
   wait_for_entity(HERO1, HERO1);
   set_autoparty(0);
   change_map("townx4","grimsby_arrive");  
end


 return
end

function refresh()
  return
end

function postexec()
  return                                                      
end

function zone_handler(zn)
  if (zn == 1) then
    change_map("townx","mal_enter");
 
  elseif (zn == 2) then
    if (in_forest(HERO1)) then
      combat(27);
    else
      combat(24);
    
    end

  elseif (zn == 3) then
    if (in_forest(HERO1)) then
      combat(29); 
    end

   elseif (zn == 4) then
    if (in_forest(HERO1)) then
      combat(33);
    end

  elseif (zn == 5) then
    if (get_progress(P_QUEST1) == 0) then
      bubble(HERO1,"Its locked.")
    elseif (get_progress(P_QUEST1) == 1) then
      bubble(HERO2,"I have the key here somewhere... here it is.");
      change_map("cavex1","cave_enter");
      set_progress(P_QUEST1,2)
      set_progress(P_CAVEDOOR,1)
      set_mtile("cave_door", 54)
      set_obs("cave_door",0)
    else
      change_map("cavex1","cave_enter");
    end
 
  elseif (zn == 6) then
    change_map("townx4","grimsby_enter");

  elseif (zn == 7) then
    change_map("capital", "cap_enter");

 
  elseif (zn == 8) then
    change_map("glade2","glade_enter");  

  elseif (zn == 9) then
    change_map("glade","glade_enter");
  
  elseif (zn == 10) then
    change_map("capital","w_enter");  

  elseif (zn == 11) then
    change_map("villagex","vil_enter");
 
  elseif (zn == 12) then
    change_map("shrine","shrine_enter");  

   
    
end

function entity_handler(en)
  if (en == 0) then
    bubble(en,"You cannot pass here.");
 
  elseif (en == 1) then
    bubble(en,"You cannot pass here.");
  end

end

end
